/**
 * The code of this mod element is always locked.
 *
 * You can register new events in this class too.
 *
 * If you want to make a plain independent class, create it using
 * Project Browser -> New... and make sure to make the class
 * outside com.hlft.ancienttinkers as this package is managed by MCreator.
 *
 * If you change workspace package, modid or prefix, you will need
 * to manually adapt this file to these changes or remake it.
 *
 * This class will be added in the mod root package.
*/
package com.hlft.ancienttinkers;

import com.hlft.ancienttinkers.block.AncientCeremonyStageBlock;
import com.hlft.ancienttinkers.block.AncientCeremonyStageBookBlock;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.block.BlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BlockRendererDispatcher;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.state.BooleanProperty;
import net.minecraft.state.DirectionProperty;
import net.minecraftforge.client.model.data.EmptyModelData;
import net.minecraftforge.fml.common.Mod;

import static com.hlft.ancienttinkers.block.AncientCeremonyStageBlock.CustomBlock.FACING;

@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
public class AncientCeremonyStageBookBlockTER extends TileEntityRenderer<AncientCeremonyStageBlock.CustomTileEntity> {

	public AncientCeremonyStageBookBlockTER(TileEntityRendererDispatcher rendererDispatcherIn) {
		super(rendererDispatcherIn);
	}
	@Override
	public void render(AncientCeremonyStageBlock.CustomTileEntity tileEntityIn, float partialTicks, MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int combinedLightIn, int combinedOverlayIn) {
		DirectionProperty directionProperty = (DirectionProperty) tileEntityIn.getBlockState().getBlock().getStateContainer().getProperty("facing");
		BooleanProperty booleanProperty = (BooleanProperty) tileEntityIn.getBlockState().getBlock().getStateContainer().getProperty("perch");
		if (tileEntityIn.getBlockState().get(booleanProperty)) {
			matrixStackIn.push();
			matrixStackIn.translate(0, 0, 0);
			BlockRendererDispatcher blockRenderer = Minecraft.getInstance().getBlockRendererDispatcher();
			BlockState state = AncientCeremonyStageBookBlock.block.getDefaultState().with(FACING, tileEntityIn.getBlockState().get(directionProperty));
			blockRenderer.renderBlock(state, matrixStackIn, bufferIn, combinedLightIn, combinedOverlayIn, EmptyModelData.INSTANCE);
			matrixStackIn.pop();
		}
	}
}
